/**
 * Created by hanfei on 18/11/15.
 */
/**
 * 下载文件链接
 */
var FileUtil = {
    downFile: function (url, data) {
        if (url && data) {
            var inputs = '';
            for (var p in data) {
                inputs += '<input type="hidden" name="' + p + '" value="' + data[p]
                    + '" />';
            }
            $('<form action="' + url + '" method="post">' + inputs + '</form>')
                .appendTo('body').submit().remove();
        }
    },

    exportExcel: function (exportUrl, par, downloadUrl) {
        $.post(exportUrl, par,
            function (data) {
                if (data.success) {
                    layer.msg('导出成功.');
                    FileUtil.downFile(downloadUrl, data.data);
                } else {
                    layer.msg('导出失败,请稍后重试.');
                }
            }, "json");
    }
}